module SevenSegEncoder (
	
	input [7:0] LSBBinary,	//The LSB binary value input
	input [7:0] MSBBinary,	//The MSB bianry value input
	input ModeSel,				//Control signal for the interal Reverser
	
	output [6:0] HexMSBH,	//The 7-Seg display Signal for higer-digit in MSB
	output [6:0] HexMSBL,	//The 7-Seg display Signal for lower-digit in MSB
	output [6:0] HexLSBH,	//The 7-Seg display Signal for higer-digit in LSB
	output [6:0] HexLSBL		//The 7-Seg display Signal for lower-digit in LSB
	

);

	wire [7:0] bcdLsb;
	wire [7:0] bcdMsb;

	wire [7:0] segLsbH;
	wire [7:0] segLsbL;
	wire [7:0] segMsbH;
	wire [7:0] segMsbL;
	
	wire [7:0] LSB_Reverser_output;
	wire [7:0] MSB_Reverser_output;


	BinaryToBCD bcd1 (
		.Binary_in(LSBBinary),
		.Bcd_Out(bcdLsb)
	);

	BinaryToBCD bcd2 (
		.Binary_in(MSBBinary),
		.Bcd_Out(bcdMsb)
	);
	
	Reverser RV_LSB(
		.RevIn(bcdLsb),
		.ModeSel(ModeSel),
		.RevOut(LSB_Reverser_output)
	);

	Reverser RV_MSB(
		.RevIn(bcdMsb),
		.ModeSel(ModeSel),
		.RevOut(MSB_Reverser_output)
	);

	BCDToSeg seg1 (
		.BCD_in(LSB_Reverser_output[7:4]),
		.Seg_out(segLsbH)
	);

	BCDToSeg seg2 (
		.BCD_in(LSB_Reverser_output[3:0]),
		.Seg_out(segLsbL)
	);

	BCDToSeg seg3 (
		.BCD_in(MSB_Reverser_output[7:4]),
		.Seg_out(segMsbH)
	);

	BCDToSeg seg4 (
		.BCD_in(MSB_Reverser_output[3:0]),
		.Seg_out(segMsbL)
	);

	assign HexLSBH = segLsbH[6:0];
	assign HexLSBL = segLsbL[6:0];
	assign HexMSBH = segMsbH[6:0];
	//assign HexMSBH = (MSB_Reverser_output[7:4] == 4'b0000) ? 7'b111_1111 : segMsbH[6:0];
	assign HexMSBL = segMsbL[6:0];

endmodule